package com.ruoyi.dmsIms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.sign.Md5Utils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dmsIms.domain.TestNote;
import com.ruoyi.dmsIms.service.ITestNoteService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 文档合集Controller
 * 
 * @author ZhangSiRui
 * @date 2022-01-14
 */
@RestController
@RequestMapping("/dmsIms/note")
public class TestNoteController extends BaseController
{
    @Autowired
    private ITestNoteService testNoteService;

    /**
     * 查询文档合集列表
     */
    @PreAuthorize("@ss.hasPermi('dmsIms:note:list')")
    @GetMapping("/list")
    public TableDataInfo list(TestNote testNote)
    {
        startPage();
        List<TestNote> list = testNoteService.selectTestNoteList(testNote);
        return getDataTable(list);
    }

    /**
     * 导出文档合集列表
     */
    @PreAuthorize("@ss.hasPermi('dmsIms:note:export')")
    @Log(title = "文档合集", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TestNote testNote)
    {
        List<TestNote> list = testNoteService.selectTestNoteList(testNote);
        ExcelUtil<TestNote> util = new ExcelUtil<TestNote>(TestNote.class);
        util.exportExcel(response, list, "文档合集数据");
    }

    /**
     * 获取文档合集详细信息
     */
    @PreAuthorize("@ss.hasPermi('dmsIms:note:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(testNoteService.selectTestNoteById(id));
    }

    /**
     * 新增文档合集
     */
    @PreAuthorize("@ss.hasPermi('dmsIms:note:add')")
    @Log(title = "文档合集", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TestNote testNote)
    {
        return toAjax(testNoteService.insertTestNote(testNote));
    }

    /**
     * 修改文档合集
     */
    @PreAuthorize("@ss.hasPermi('dmsIms:note:edit')")
    @Log(title = "文档合集", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TestNote testNote)
    {
        return toAjax(testNoteService.updateTestNote(testNote));
    }

    /**
     * 删除文档合集
     */
    @PreAuthorize("@ss.hasPermi('dmsIms:note:remove')")
    @Log(title = "文档合集", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(testNoteService.deleteTestNoteByIds(ids));
    }
}
